<?php 

// $user_info['real_name'] = '罗世强';

// $last_name_len = mb_strlen($user_info['real_name'], 'UTF8') - 1; //获取名的UTF8长度
// echo $last_name_len;
// $first_name = mb_substr($user_info['real_name'], 0, 1, 'UTF8'); //截取姓
// $user_info['real_name'] = str_pad($first_name, 3 + $last_name_len, '*'); //填充*

// echo $user_info['real_name'];

$user_info['identity_num'] = '(02014-1111121';

// $pattern = "\(?0\d{2}\)?[-]?\d{8}|0\d{2}[-]?\d{8}";
// $pattern = '/\(0\d{2}\)[-]?\d{8}|0\d{2}[-]?\d{8}|\(0\d{3}\)[-]?\d{7}/';
$pattern = '/^\(?0\d{2}\)?[-]?\d{8}|0\d{2}[-]?\d{8}|\(?0\d{3}\)?[-]?\d{7}$/';
preg_match($pattern, $user_info['identity_num'], $match);
var_dump($match);
// $str_mid = $match[1]; //中间n位
// echo $str_mid;
// $str_star = str_pad('', strlen($str_mid), '*');
// $user_info['identity_num'] = str_replace($str_mid, $str_star, $user_info['identity_num']);

?>